package com.zxp.rmi.client;

import com.zxp.rmi.service.HelloRegistryFacade;
import lombok.SneakyThrows;

import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * @author zxp
 * @date 2021-08-23 10:31
 */
public class RegistryClient {

    @SneakyThrows
    public static void main(String[] args) {
        // 从注册中心中拿到远程服务
        Registry registry = LocateRegistry.getRegistry(8989);
        HelloRegistryFacade hello = (HelloRegistryFacade) registry.lookup("HelloRegistry");
        //HelloRegistryFacade hello = (HelloRegistryFacade) Naming.lookup("rmi://localhost:8989/demoService");
        String response = hello.hello("ZXP");
        System.out.println("=======> " + response + " <=======");
    }
}
